<template>
  <div class="wrapper">
    <HeaderView></HeaderView>
    <SidebarView></SidebarView>
    <div class="content-box" :class="{ 'content-collapse': sidebar.collapse }">
      <TagsView></TagsView>
      <div class="content" id="target">
        <el-watermark :font="font" :content="content">
          <router-view v-slot="{ Component }">
            <transition name="fade-transform" mode="out-in">
              <keep-alive :include="tags.nameList">
                <component :is="Component" />
              </keep-alive>
            </transition>
          </router-view>
        </el-watermark>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ElWatermark } from "element-plus";
import { useSidebarStore } from "@/store/sidebar";
import { useTagsStore } from "@/store/tags";
import HeaderView from "@/components/homeView/HeaderView.vue";
import SidebarView from "@/components/homeView/SidebarView.vue";
import TagsView from "@/components/homeView/TagsView.vue";
import { useUserStore } from "@/store/user";
import { dateFormatYMDHMS } from "@/utils/utils";
const sidebar = useSidebarStore();
const tags = useTagsStore();
/* 用户信息 */
const userStore = useUserStore();
const userInfo = userStore.userInfo;
const font = reactive({
  color: "rgba(0, 0, 0, .15)"
});
const content = ref<string[]>([]);
content.value.push(userInfo.nick_name + userInfo.user_name, dateFormatYMDHMS(new Date().getTime()));

watch(
  () => userInfo.nick_name,
  () => {
    content.value = [];
    content.value.push(userInfo.nick_name + userInfo.user_name, dateFormatYMDHMS(new Date().getTime()));
  }
);
</script>
<style scoped>
.content {
  overflow-y: auto;
}

.content-box {
  background-color: #f8f8f8;
}

.fade-transform-leave-active {
  animation: fade-transform-in 0.5s;
}

.fade-transform-enter-active {
  animation: fade-transform-out 0.8s;
}

@keyframes fade-transform-in {
  from {
    opacity: 1;
  }

  to {
    transform: translateX(30px);
    opacity: 0;
  }
}

@keyframes fade-transform-out {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 0.8;
  }
}
</style>
